package com.sunseaypw.console;

import java.util.ArrayList;

/*
    K extends Number 可限定K泛型类型为Number以及Number的子类。
*/
public class StaticGeneric<T,K extends Number> {
    public T name;
    public StaticGeneric(T _name){
        this.name=_name;
    }
    public K sub;
    public StaticGeneric(Class<K> kc,Object[] args){
        try{
            this.sub=kc.getConstructor(String.class).newInstance(args[0]);
        }catch(Exception ex){
            System.out.println(ex.toString());
        }        
    }

    public K getSub2(){
        return this.sub;
    }
    public T getName(){
        return this.name;
    }
    public void setName(T val){
        this.name=val;
    }
    // 静态泛型方法应该使用其他类型区分:
    public static <K,L> ArrayList<K> create(K a,L b) {
        var aa=new ArrayList<K>();
        aa.add(a);
        return aa;
    }
}
